package com.xbongbong.pro.enums.global;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.Objects;

@Getter
public enum PaasFormEnum {
    /**
     * crm模块
      */
    CUSTOMER_MANAGEMENT("enum.redundantTemplateType.name.customer", XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getAlias(), XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode()),
    CUSTOMER("enum.cRMMenu.name.customer", XbbRefTypeEnum.CUSTOMER.getAlias(), XbbRefTypeEnum.CUSTOMER.getCode()),
    CUSTOMER_FOCUS("enum.cRMMenu.name.customer_focus", XbbRefTypeEnum.CUSTOMER_FOCUS.getAlias(), XbbRefTypeEnum.CUSTOMER_FOCUS.getCode()),
    CUSTOMER_DEAL("enum.cRMMenu.name.customer_deal", XbbRefTypeEnum.CUSTOMER_DEAL.getAlias(), XbbRefTypeEnum.CUSTOMER_DEAL.getCode()),
    CUSTOMER_FOLLOW("enum.cRMMenu.name.customer_follow", XbbRefTypeEnum.CUSTOMER_FOLLOW.getAlias(), XbbRefTypeEnum.CUSTOMER_FOLLOW.getCode()),
    CUSTOMER_PUBLIC("enum.cRMMenu.name.customer_public", XbbRefTypeEnum.CUSTOMER_PUBLIC.getAlias(), XbbRefTypeEnum.CUSTOMER_PUBLIC.getCode()),
    CUSTOMER_DUPLICATE("enum.cRMMenu.name.customer_duplicate", XbbRefTypeEnum.CUSTOMER_DUPLICATE.getAlias(), XbbRefTypeEnum.CUSTOMER_DUPLICATE.getCode()),
    CUSTOMER_RECYCLE("enum.cRMMenu.name.customer_recycle", XbbRefTypeEnum.CUSTOMER_RECYCLE.getAlias(), XbbRefTypeEnum.CUSTOMER_RECYCLE.getCode()),
    CUSTOMER_NEARBY("enum.cRMMenu.name.customer_nearby", XbbRefTypeEnum.CUSTOMER_NEARBY.getAlias(), XbbRefTypeEnum.CUSTOMER_NEARBY.getCode()),
    CONTACT("enum.cRMMenu.name.contact", XbbRefTypeEnum.CONTACT.getAlias(), XbbRefTypeEnum.CONTACT.getCode()),
    //跟进记
    CUSTOMER_COMMUNICATE("enum.cRMMenu.name.customer_communicate", XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getAlias(), XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode()),
    //访客计划
    COMMUNICATE_PLAN("enum.cRMMenu.name.communicate_plan", XbbRefTypeEnum.COMMUNICATE_PLAN.getAlias(), XbbRefTypeEnum.COMMUNICATE_PLAN.getCode()),
    //销售机会
    SALES_OPPORTUNITY("enum.cRMMenu.name.sales_opportunity", XbbRefTypeEnum.SALES_OPPORTUNITY.getAlias(), XbbRefTypeEnum.SALES_OPPORTUNITY.getCode()),
    ALL_OPPORTUNITY("enum.cRMMenu.name.all_opportunity", XbbRefTypeEnum.ALL_OPPORTUNITY.getAlias(), XbbRefTypeEnum.ALL_OPPORTUNITY.getCode()),
    KEY_OPPORTUNITY("enum.cRMMenu.name.key_opportunity", XbbRefTypeEnum.KEY_OPPORTUNITY.getAlias(), XbbRefTypeEnum.KEY_OPPORTUNITY.getCode()),
    QUOTATION("enum.cRMMenu.name.quotation", XbbRefTypeEnum.QUOTATION.getAlias(), XbbRefTypeEnum.QUOTATION.getCode()),
    //合同订单
    CONTRACT("enum.cRMMenu.name.contract",XbbRefTypeEnum.CONTRACT.getAlias(),XbbRefTypeEnum.CONTRACT.getCode()),
    // 退货退款
    REFUND("enum.cRMMenu.name.refund",XbbRefTypeEnum.REFUND.getAlias(),XbbRefTypeEnum.REFUND.getCode()),
    //签到
    SIGN_IN("enum.cRMMenu.name.sign_in", XbbRefTypeEnum.SIGNIN.getAlias(), XbbRefTypeEnum.SIGNIN.getCode()),
    //工作报告
    WORK_REPORT("enum.cRMMenu.name.work_report", XbbRefTypeEnum.WORK_REPORT.getAlias(), XbbRefTypeEnum.WORK_REPORT.getCode()),
    CONTRACT_PRODUCT("enum.bIProduct.name.contract_product","contract_product",204),
    CONTRACT_PERFORMANCE("enum.xbbRefType.name.contract_performance","contract_performance", 206),
    /**
     * 进销存菜单枚举
     */
    PURCHASE_MANAGEMENT(XbbRefTypeEnum.PURCHASE_MANAGEMENT.getI18nName(), XbbRefTypeEnum.PURCHASE_MANAGEMENT.getAlias(), XbbRefTypeEnum.PURCHASE_MANAGEMENT.getCode()),
    SUPPLIER(XbbRefTypeEnum.SUPPLIER.getI18nName(), XbbRefTypeEnum.SUPPLIER.getAlias(), XbbRefTypeEnum.SUPPLIER.getCode()),
    SUPPLIER_CONTACT(XbbRefTypeEnum.SUPPLIER_CONTACT.getI18nName(), XbbRefTypeEnum.SUPPLIER_CONTACT.getAlias(), XbbRefTypeEnum.SUPPLIER_CONTACT.getCode()),
    SUPPLIER_CUSTOMER_COMMUNICATE(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getI18nName(), XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getAlias(), XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode()),
    // 采购合同
    PURCHASE(XbbRefTypeEnum.PURCHASE.getI18nName(), XbbRefTypeEnum.PURCHASE.getAlias(), XbbRefTypeEnum.PURCHASE.getCode()),
    // 采购退货
    RETURNED_PURCHASE(XbbRefTypeEnum.RETURNED_PURCHASE.getI18nName(), XbbRefTypeEnum.RETURNED_PURCHASE.getAlias(), XbbRefTypeEnum.RETURNED_PURCHASE.getCode()),
    PRODUCTION_MANAGEMENT(XbbRefTypeEnum.PRODUCTION_MANAGEMENT.getI18nName(), XbbRefTypeEnum.PRODUCTION_MANAGEMENT.getAlias(), XbbRefTypeEnum.PRODUCTION_MANAGEMENT.getCode()),
    BOM_BILL(XbbRefTypeEnum.BOM_BILL.getI18nName(), XbbRefTypeEnum.BOM_BILL.getAlias(), XbbRefTypeEnum.BOM_BILL.getCode()),
    // 模拟生产
    SIMULATED_PRODUCTION(XbbRefTypeEnum.SIMULATED_PRODUCTION.getI18nName(), XbbRefTypeEnum.SIMULATED_PRODUCTION.getAlias(), XbbRefTypeEnum.SIMULATED_PRODUCTION.getCode()),
    PRODUCTION_ORDER(XbbRefTypeEnum.PRODUCTION_ORDER.getI18nName(), XbbRefTypeEnum.PRODUCTION_ORDER.getAlias(), XbbRefTypeEnum.PRODUCTION_ORDER.getCode()),
    INVENTORY_MANAGEMENT(XbbRefTypeEnum.INVENTORY_MANAGEMENT.getI18nName(), XbbRefTypeEnum.INVENTORY_MANAGEMENT.getAlias(), XbbRefTypeEnum.INVENTORY_MANAGEMENT.getCode()),
    // 装配出入库单
    ASSEMBLE(XbbRefTypeEnum.ASSEMBLE.getI18nName(), XbbRefTypeEnum.ASSEMBLE.getAlias(), XbbRefTypeEnum.ASSEMBLE.getCode()),
    // 盘点单
    INVENTORY(XbbRefTypeEnum.INVENTORY.getI18nName(), XbbRefTypeEnum.INVENTORY.getAlias(), XbbRefTypeEnum.INVENTORY.getCode()),
    // 调拨单
    TRANSFER(XbbRefTypeEnum.TRANSFER.getI18nName(), XbbRefTypeEnum.TRANSFER.getAlias(), XbbRefTypeEnum.TRANSFER.getCode()),
    // 库存查询
    STOCK_SEARCH(XbbRefTypeEnum.STOCK_SEARCH.getI18nName(), XbbRefTypeEnum.STOCK_SEARCH.getAlias(), XbbRefTypeEnum.STOCK_SEARCH.getCode()),
    STOCK_FLOW_BILL(XbbRefTypeEnum.STOCK_FLOW_BILL.getI18nName(), XbbRefTypeEnum.STOCK_FLOW_BILL.getAlias(), XbbRefTypeEnum.STOCK_FLOW_BILL.getCode()),
    STOCK_STANDING_BOOK(XbbRefTypeEnum.STOCK_STANDING_BOOK.getI18nName(), XbbRefTypeEnum.STOCK_STANDING_BOOK.getAlias(), XbbRefTypeEnum.STOCK_STANDING_BOOK.getCode()),
    INSTOCK_MANAGEMENT(XbbRefTypeEnum.INSTOCK.getI18nName(), XbbRefTypeEnum.INSTOCK.getAlias(), XbbRefTypeEnum.INSTOCK.getCode()),
    // 采购入库单
    PURCHASE_INSTOCK(XbbRefTypeEnum.PURCHASE_INSTOCK.getI18nName(), XbbRefTypeEnum.PURCHASE_INSTOCK.getAlias(), XbbRefTypeEnum.PURCHASE_INSTOCK.getCode()),
    // 销售退货入库
    REFUND_INSTOCK(XbbRefTypeEnum.REFUND_INSTOCK.getI18nName(), XbbRefTypeEnum.REFUND_INSTOCK.getAlias(), XbbRefTypeEnum.REFUND_INSTOCK.getCode()),
    // 其他入库单
    OTHER_INSTOCK(XbbRefTypeEnum.OTHER_INSTOCK.getI18nName(), XbbRefTypeEnum.OTHER_INSTOCK.getAlias(), XbbRefTypeEnum.OTHER_INSTOCK.getCode()),
    //生产入库单
    PRODUCTION_INSTOCK(XbbRefTypeEnum.PRODUCTION_INSTOCK.getI18nName(), XbbRefTypeEnum.PRODUCTION_INSTOCK.getAlias(), XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode()),
    //生产退料单
    RETURNED_MATERIEL_INSTOCK(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getI18nName(), XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getAlias(), XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode()),
    OUTSTOCK_MANAGEMENT(XbbRefTypeEnum.OUTSTOCK.getI18nName(), XbbRefTypeEnum.OUTSTOCK.getAlias(), XbbRefTypeEnum.OUTSTOCK.getCode()),
    // 销售出库单
    CONTRACT_OUTSTOCK(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getI18nName(), XbbRefTypeEnum.CONTRACT_OUTSTOCK.getAlias(), XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode()),
    // 采购退货出库单
    RETURNED_PURCHASE_OUTSTOCK(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getI18nName(), XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getAlias(), XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode()),
    // 其他出库单
    OTHER_OUTSTOCK(XbbRefTypeEnum.OTHER_OUTSTOCK.getI18nName(), XbbRefTypeEnum.OTHER_OUTSTOCK.getAlias(), XbbRefTypeEnum.OTHER_OUTSTOCK.getCode()),
    // 生产领料单
    PRODUCTION_MATERIEL_OUTSTOCK(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getI18nName(), XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getAlias(), XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode()),
    // 工单出库单
    WORK_ORDER_OUTSTOCK(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getI18nName(), XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getAlias(), XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode()),
    // 仓库
    WAREHOUSE(XbbRefTypeEnum.WAREHOUSE.getI18nName(), XbbRefTypeEnum.WAREHOUSE.getAlias(), XbbRefTypeEnum.WAREHOUSE.getCode()),
    // 产品管理
    PRODUCT("enum.redundantTemplateType.name.product", XbbRefTypeEnum.PRODUCT.getAlias(), XbbRefTypeEnum.PRODUCT.getCode()),

    SALES_OPPORTUNITY_PRODUCT("enum.bIProduct.name.sales_opportunity_product","salesOpportunityProduct",306),
    /**
     * 资金管理枚举类
     */
    PAYMENT_MANAGEMENT("enum.fundManagementMenu.name.payment_management", XbbRefTypeEnum.PAYMENT_MANAGEMENT.getAlias(), XbbRefTypeEnum.PAYMENT_MANAGEMENT.getCode()),
    PAYMENT("enum.fundManagementMenu.name.payment", XbbRefTypeEnum.PAYMENT.getAlias(), XbbRefTypeEnum.PAYMENT.getCode()),
    PAYMENT_SHEET("enum.fundManagementMenu.name.payment_sheet", XbbRefTypeEnum.PAYMENT_SHEET.getAlias(), XbbRefTypeEnum.PAYMENT_SHEET.getCode()),
    PREPAYMENT_BLANCE("enum.fundManagementMenu.name.prepayment_blance", XbbRefTypeEnum.PREPAYMENT_BALANCE.getAlias(), XbbRefTypeEnum.PREPAYMENT_BALANCE.getCode()),
    PAY_MANAGEMENT("enum.fundManagementMenu.name.pay_management", XbbRefTypeEnum.PAY_MANAGEMENT.getAlias(), XbbRefTypeEnum.PAY_MANAGEMENT.getCode()),
    PAY_PLAN("enum.fundManagementMenu.name.pay_plan", XbbRefTypeEnum.PAY_PLAN.getAlias(), XbbRefTypeEnum.PAY_PLAN.getCode()),
    PAY_SHEET("enum.fundManagementMenu.name.pay_sheet", XbbRefTypeEnum.PAY_SHEET.getAlias(), XbbRefTypeEnum.PAY_SHEET.getCode()),
    PREPAY_BLANCE("enum.fundManagementMenu.name.prepay_blance", XbbRefTypeEnum.PREPAY_BALANCE.getAlias(), XbbRefTypeEnum.PREPAY_BALANCE.getCode()),
    INVOICE("enum.redundantTemplateType.name.invoice", XbbRefTypeEnum.INVOICE.getAlias(), XbbRefTypeEnum.INVOICE.getCode()),
    PURCHASE_INVOICE("enum.fundManagementMenu.name.purchase_invoice", XbbRefTypeEnum.PURCHASE_INVOICE.getAlias(), XbbRefTypeEnum.PURCHASE_INVOICE.getCode()),
    /**
     * 每刻报销枚举类
     */
    REIMBURSEMENT_FORM("enum.expenseManagementMenu.name.reimbursement_form", XbbRefTypeEnum.REIMBURSEMENT_FORM.getAlias(), XbbRefTypeEnum.REIMBURSEMENT_FORM.getCode()),

    EXPENSE("enum.expenseManagementMenu.name.expense", XbbRefTypeEnum.EXPENSE.getAlias(), XbbRefTypeEnum.EXPENSE.getCode()),
    /**
     * 短信群发枚举
     */
    CONFIG_INFORMATION("enum.groupMessageMenu.name.config_information", XbbRefTypeEnum.CONFIG_INFORMATION.getAlias(), XbbRefTypeEnum.CONFIG_INFORMATION.getCode()),
    RECHARGE_RECORD("enum.groupMessageMenu.name.recharge_record", XbbRefTypeEnum.RECHARGE_RECORD.getAlias(), XbbRefTypeEnum.RECHARGE_RECORD.getCode()),
    SEND_MESSAGE("enum.groupMessageMenu.name.send_message", XbbRefTypeEnum.SEND_MESSAGE.getAlias(), XbbRefTypeEnum.SEND_MESSAGE.getCode()),
    RECORD_VIEW("enum.groupMessageMenu.name.record_view", XbbRefTypeEnum.RECORD_VIEW.getAlias(), XbbRefTypeEnum.RECORD_VIEW.getCode()),
    REPLY_VIEW("enum.groupMessageMenu.name.reply_view", XbbRefTypeEnum.REPLY_VIEW.getAlias(), XbbRefTypeEnum.REPLY_VIEW.getCode()),
    //签到
    CALL_CENTER_CALL_LOG("enum.callCenterMenu.name.call_center_call_log", XbbRefTypeEnum.CALL_CENTER_CALL_LOG.getAlias(), XbbRefTypeEnum.CALL_CENTER_CALL_LOG.getCode()),

    //挖掘线索
    EXCAVATE_CLUE(XbbRefTypeEnum.EXCAVATE_CLUE.getI18nName(), XbbRefTypeEnum.EXCAVATE_CLUE.getAlias(), XbbRefTypeEnum.EXCAVATE_CLUE.getCode()),
    //收藏夹
    COLLECTOR(XbbRefTypeEnum.COLLECTOR.getI18nName(), XbbRefTypeEnum.COLLECTOR.getAlias(), XbbRefTypeEnum.COLLECTOR.getCode()),
    //我的线索
    INDIVIDUAL_CLUE(XbbRefTypeEnum.INDIVIDUAL_CLUE.getI18nName(), XbbRefTypeEnum.INDIVIDUAL_CLUE.getAlias(), XbbRefTypeEnum.INDIVIDUAL_CLUE.getCode()),
    //回收站
    RECYCLE_BIN(XbbRefTypeEnum.RECYCLE_BIN.getI18nName(), XbbRefTypeEnum.RECYCLE_BIN.getAlias(), XbbRefTypeEnum.RECYCLE_BIN.getCode()),
    //权限管理
    AUTHORITY_MANAGE(XbbRefTypeEnum.AUTHORITY_MANAGE.getI18nName(), XbbRefTypeEnum.AUTHORITY_MANAGE.getAlias(), XbbRefTypeEnum.AUTHORITY_MANAGE.getCode()),

    WORK_ORDER(XbbRefTypeEnum.WORK_ORDER.getI18nName(), XbbRefTypeEnum.WORK_ORDER.getAlias(), XbbRefTypeEnum.WORK_ORDER.getCode()),

    SUPPLIER_PRODUCT("enum.bIProduct.name.supplier_product","supplierProduct",1005),
    PURCHASE_PRODUCT("enum.bIProduct.name.purchase_product","purchaseProduct", 1104),
    RETURNEDPURCHASE_PRODUCT("enum.bIProduct.name.returned_purchase_product","returnedPurchase_product",1202),
    INSTOCK_PRODUCT("enum.bIProduct.name.instock_product", "instock_product",1402),
    OUTSTOCK_PRODUCT("enum.bIProduct.name.outstock_product", "outstock_product", 1502),
    WORKREPORT_DAILY("enum.xbbRefType.name.workreport_daily","workReportDaily", 2102),
    WORKREPORT_WEEKLY("enum.xbbRefType.name.workreport_weekly","workReportWeekly",2103),
    WORKREPORT_MONTHLY("enum.xbbRefType.name.workreport_monthly","workReportMonthly",2104),
    STOCK_PRODUCT("enum.xbbRefType.name.stock_product","stockProduct",2501),
    PRODUCTION_ORDER_PRODUCT("enum.bIProduct.name.production_order_product","productionOrderProduct", 2804),
    QUOTATION_PRODUCT("enum.bIProduct.name.quotation_product", "quotationProduct", 4702),
    ASSEMBLE_PRODUCT("enum.bIProduct.name.assemble_product", "assemble_product", 1302),
    ASSEMBLE_INPRODUCTS("enum.bIProduct.name.assemble_in_products",XbbRefTypeEnum.ASSEMBLE_INPRODUCTS.getAlias(), 1303),
    INVENTORY_PRODUCT("enum.bIProduct.name.inventory_product",XbbRefTypeEnum.INVENTORY_PRODUCT.getAlias(), 1702),
    TRANSFER_PRODUCT("enum.bIProduct.name.transfer_product",XbbRefTypeEnum.TRANSFER_PRODUCT.getAlias(), 1602),

    ;

    /**
     * saas应用标示解释
     */
    private String name;
    /**
     * saas应用标示
     * @see XbbRefTypeEnum
     */
    private String alias;

    private int code;

    PaasFormEnum(String name, String alias, int code) {
        this.name = name;
        this.alias = alias;
        this.code = code;
    }

    public static PaasFormEnum getByAlias (String alias) {
        for (PaasFormEnum paasFormEnum : values()) {
            if (Objects.equals(paasFormEnum.getAlias(), alias)) {
                return paasFormEnum;
            }
        }
        return null;
    }

    public static PaasFormEnum getByCode(Integer code) {
        for (PaasFormEnum paasFormEnum : values()) {
            if (Objects.equals(paasFormEnum.getCode(), code)) {
                return paasFormEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
